﻿#ifndef NAT_TESTER_H
#define NAT_TESTER_H

#include <qobject.h>
#include "ObjAutoInject.h"
#include <qtimer.h>
#include <qhash.h>
#include <qdatetime.h>
#include <qlist.h>

class Codec_NBIoT;
class LogSaver;
class UDP_Test : public QObject,public ObjAutoInject
{
  Q_OBJECT
public:
  enum RegisterType{
    Unregistered=0,
    Registered=1,
    Reset=2,
  };
  enum DataPackgeType
  {//0x00-0x0f
    HeartBeat=0,
    SensorData,
    TurnTable,
    MCUCtrl,
    Register,
    Test,
    Size
  };
private://property
  //QTimer
  QTimer timer_register;
  QTimer timer_life;
  //Timer interval
  int timer_interval_register=50*1000;//lifetime
  int timer_interval_checkConnection_NBIOT=5*1000;//check connection state between model and base
  //connection infomation
  QString socketID="0";
  //通信参数
  int deviceId=100000;
  ushort msgId=0;
  QByteArray heartBeatData;

  bool connectionState=false;
private://dependency
  Codec_NBIoT* codec_NBIoT=Q_NULLPTR;
  LogSaver* logSaver=Q_NULLPTR;
public:
  explicit UDP_Test();
  virtual ~UDP_Test();
signals:
public:
  void startTest();
  QByteArray makeRegisterData(ushort msgId);
private slots:
  void slot_register();
private slots:
  void slot_NEWSOCKETID(QString socketID);
  void slot_NEWSOCKETMSG(QString socketID,QString senderHost,ushort senderPort,int len,QByteArray data);
public://geter and seter
  Codec_NBIoT* getCodec_NBIoT();
  void setCodec_NBIoT(Codec_NBIoT* codec_NBIoT);
public:
  virtual void objectAutoInjection(QHash<QString,QObject*>* objMap)override;
};

#endif // NAT_TESTER_H
